'''
# @Title:
# @Time : 2022/3/3 17:15
# @File : demo.py
# @Software: PyCharm

'''
from hamcrest import *
from jsonpath import jsonpath
import requests


class TestDemo:

    def test_get(self):
        r = requests.get('https://httpbin.testing-studio.com/get')
        print(r.text)
        print(r.status_code)
        assert  r.status_code == 200

    # Get_Query请求
    def test_query(self):
        payload = {
            'key1':"1",
            'key2':"2",
            'name':'ttwelves'
        }
        r = requests.get('https://httpbin.testing-studio.com/get', params=payload)
        print(r.text)
        assert r.status_code == 200

    # Form请求参数构造
    def test_post_form(self):
        payload = {
            'key1':"1",
            'key2':"2",
            'name':'ttwelves'
        }
        r = requests.post('https://httpbin.testing-studio.com/post', data=payload)
        print(r.text)
        assert r.status_code == 200

    # json结构体参数构造
    def test_post_json(self):
        payload = {
            'key1': "1",
            'key2': "2",
            'name': 'ttwelves'
        }
        r = requests.post('https://httpbin.testing-studio.com/post', json=payload)
        print(r.text)
        assert r.status_code == 200

    # 注意jsonpath的使用方法
    def test_hogwarts_json(self):
        r = requests.get('https://ceshiren.com/categories.json')
        print(r.text)
        assert r.status_code == 200
        assert r.json()['category_list']['categories'][0]['name'] == '开源项目'
        print(jsonpath(r.json(), '$..name'))
        assert jsonpath(r.json(), '$..name')[0] == '开源项目'


    def test_hamcrest(self):
        assert_that









